package features.advance.jdk.shell;

import lombok.extern.slf4j.Slf4j;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author LIN
 * @date 2022-12-15 16:06
 */
@Slf4j
public class Demo {

    public static void main(String[] args) throws IOException, InterruptedException {
        ProcessBuilder processBuilder = new ProcessBuilder();
        String command = "D:\\project-2022\\yqjr\\pm\\nmps\\echo.bat";

        ProcessBuilder pb = processBuilder.command(command);
        Process p = pb.start();

        int runningStatus = 0;
        String s="";

        BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
        while ((s = stdInput.readLine()) != null) {
            System.out.println("input:"+s);
        }
        while ((s = stdError.readLine()) != null) {
            System.out.println("error:"+s);
        }
        stdError.close();
        stdInput.close();

    }


}
